@using Microsoft.AspNetCore.Identity
@using Microsoft.Extensions.Options
@using OrchardCore.Admin
@using OrchardCore.Entities
@using OrchardCore.Settings
@using OrchardCore.Users
@using OrchardCore.Users.Models
@using Microsoft.AspNetCore.Authorization
@inject ISiteService SiteService
@inject SignInManager<IUser> SignInManager
@inject IOptions<AdminOptions> AdminOptions
  @inject Microsoft.AspNetCore.Authorization.IAuthorizationService authorizationService

@{
    var allowChangeEmail = (await SiteService.GetSiteSettingsAsync()).As<ChangeEmailSettings>().AllowChangeEmail;
    var canAccessAdmin = await authorizationService.AuthorizeAsync(User, OrchardCore.Admin.Permissions.AccessAdminPanel);
    var externalAuthenticationSchemes = await SignInManager.GetExternalAuthenticationSchemesAsync();
}
@if (User.Identity.IsAuthenticated)
{
  <v-menu>
    <template v-slot:activator="{ on, attrs }">
      <v-btn icon v-bind="attrs" v-on="on">
        <v-icon>mdi-account</v-icon>
      </v-btn>
    </template>
    <v-list>
      @if(canAccessAdmin) 
      {
      <v-list-item href="@Url.Action("Index", "Admin", new { Area = "OrchardCore.Admin" })">
        <v-list-item-icon>
          <v-icon>mdi-monitor-dashboard</v-icon>
        </v-list-item-icon>
        <v-list-item-title>@T["Dashboard"]</v-list-item-title>
      </v-list-item>
      <v-divider></v-divider>
      }
      <v-list-item href="@Url.Action("ChangePassword", "Account", new { Area = "OrchardCore.Users" })">
        <v-list-item-icon>
          <v-icon>mdi-account-key</v-icon>
        </v-list-item-icon>
        <v-list-item-title>@T["Change Password"]</v-list-item-title>
      </v-list-item>
      @if (allowChangeEmail)
      {
      <v-list-item href="@Url.Action("Index", "ChangeEmail", new { Area = "OrchardCore.Users" })">
        <v-list-item-icon>
          <v-icon>mdi-email</v-icon>
        </v-list-item-icon>
        <v-list-item-title>@T["Change Email"]</v-list-item-title>
      </v-list-item>
      }
      @if (externalAuthenticationSchemes.Count() > 0)
      {
      <v-list-item href="@Url.Action("ExternalLogins", "Account", new { Area = "OrchardCore.Users" })">
        <v-list-item-icon>
          <v-icon>mdi-account-cog</v-icon>
        </v-list-item-icon>
        <v-list-item-title>@T["External Logins"]</v-list-item-title>
      </v-list-item>
      }
      <v-divider></v-divider>
      <form asp-route-area="OrchardCore.Users" asp-controller="Account" asp-action="LogOff" method="post">
        <v-list-item link tag="button" type="submit" style="width:100%">
          <v-list-item-icon>
            <v-icon>mdi-logout</v-icon>
          </v-list-item-icon>
          <v-list-item-title class="text-left">@T["Log off"]</v-list-item-title>
        </v-list-item>
      </form>
    </v-list>
  </v-menu>
}
else
{
  <v-btn icon href="@Url.Action("Login", "Account", new { Area = "OrchardCore.Users" })" title="@T["Log in"]">
    <v-icon>mdi-login</v-icon>
  </v-btn>
}